		
	*** Set dates
		local month 10
		local day 15
		local date "`month'.`day'.2020"
		if length("`month'") == 1 {
			local month = "0" + "`month'"
		}
		local treatmonth 10 
		local treatday 12
		
	*** Load data
		use "$root/DATA/Raw_Survey_Data/`date'.dta", clear
		
	*** Keep the relevant responses	
		keep if consent == 1 & age >= 18
		drop if key == "uuid:43a26fa9-cc26-45e1-a06b-4fea97cd5376" // Duplicate
		drop if key == "uuid:5a11e8ae-e521-4e12-aced-2abe08116497" // One distancing person who is in a handwashing round
		drop if inlist(key, "uuid:60e3d4b2-5d11-4a4f-bc2f-ee6d5774db0b", "uuid:ecd3efec-825e-4a53-87cc-796cf7930b40", "uuid:3dfe9630-d1fd-473b-a9be-206431856080") // Handwashing person in distancing round
		drop if inlist(scramble_id, 758, 2955, 5030, 17665, 17934) // 8.30 interviews that don't match treatment assignments
		drop if inlist(scramble_id, 6259) // 9.02 interview that didn't match treatment assignments 
		drop if key == "uuid:650aa5bb-1bd3-4cab-98ee-dbcbf696d513" // Handwashing in a distance round
		drop if scramble_id == 10067 // control interviewed a day later on 9/11
		drop if inlist(scramble_id, 2138, 12983)  
		drop if inlist(scramble_id, 4085, 6057, 7197, 13026)
		drop if inlist(scramble_id, 4675, 5419, 10418, 15371)
		drop if inlist(scramble_id, 561, 1873, 6772, 10984)
		drop if inlist(scramble_id, 8489)
		drop if scramble_id == 6895 & complete == 555 // duplicate ID, drop the incomplete one
		drop if scramble_id == 12284
		drop if scramble_id == 5430
		drop if scramble_id == 2055 // two of the same, not sure which is right 
		drop if scramble_id == 5356 | scramble_id == 6501
		drop if scramble_id == 17125
		
	*** Check that each person is unique	
		gisid scramble_id
		rename scramble_id scrambledid
		
	*** Merge in treatment assignments	
		merge 1:1 scrambledid using "$root/DATA/Adaptive_Trial_Output/Treatment_assignments/sms_assignments_`treatmonth'`treatday'20.dta"
		
	*** Correct treatments for day when delays happened in SMS
		if "`treatmonth'" == "08" & ("`treatday'" == "22" | "`treatday'" == "23") {
			replace treatment = 6 if treatment == 1
			replace treatment = 7 if treatment == 2
			replace treatment = 8 if treatment == 3
			replace treatment = 9 if treatment == 4
			replace treatment = 10 if treatment == 5
		}
		
	*** Drop unreached people	
		drop if _merge == 2

	*** Check that everyone has an assigned treatment 	
		assert _merge == 3
	
	*** Create outcomes of interest 
		gen distancingoutcome = protection_use_6
		replace distancingoutcome = protection_use2_6 if missing(protection_use_6)
		gen handwashingoutcome = 1 if protection_use_1 == 1 | protection_use_2 == 1 | protection_use2_1 == 1 | protection_use2_2 == 1
		replace handwashingoutcome = 0 if missing(handwashingoutcome) & (!missing(protection_use_1) | !missing(protection_use2_1))
		
	*** Check that no one is missing outcome of interest 	
		gen smstype = lower(cal_scramble_id)
		local outcome = smstype[1]
		assert !missing(`outcome'outcome) if complete == 1
		rename `outcome'outcome outcome 
		drop if missing(outcome)
	
	*** Check that not missing treatment 
		drop if scrambledid == 4445 | scrambledid == 10861 // Two people who were missing treatment for some reason 
		drop if scrambledid == 17238 // missing treatment 
		drop if inlist(scrambledid, 1934, 3954, 7571, 8300, 10154, 10309, 12696, 17187) // missing treatment
		assert !missing(treatment)
		gen temp = treatment 
		drop treatment
		rename temp treatment
		keep treatment outcome
		tempfile newdata
		save `newdata'		
		use "$output/`outcome'priors.dta", clear 
		append using `newdata'
		save "$output/`outcome'priors.dta", replace 
		export delimited "$output/2020-`month'-`day'priors.csv", replace 
